import os.path
# file=open('./1.txt','r',encoding='utf-8')
# #文件不存在 报错 FileNotFoundError
# print(file.read())
# file.close()

#自动关闭文件
# with open('./1.txt', 'r', encoding='utf-8') as file:
    # print(file.read(2))
    # print(file.read(1))
    # print(file.readline().strip())
    # print(file.readline().strip())
    # print(file.readline().strip())
    # print(file.readline().strip())
    # while True:
    #     line = file.readline()
    #     if not line:
    #         break
    #     print(line.strip())

    # list = file.readlines()
    # print(list)

# list=['a1','b1','c1']
# #a模式，追加内容，原有内容不覆盖
# with open('./2.txt', mode='a', encoding='utf-8') as file:
#     # file.write('hello world\n')
#     # file.write('我的祖国')
#     file.writelines(list)

#图片复制
# with open('./a.png', 'rb') as file:
#     #windows 绝对路径 / 或者 \\
#     with open('D:\\picture\\20251106.png','wb') as file2:
#         while True:
#             data = file.read(1024)
#             if not data:
#                 break
#             file2.write(data)

# flag=os.path.exists('D:\\picture')
# flg2=os.path.exists('D:\\picture111')
# print(flag)
# print(flg2)
# os.makedirs('D:\\picture111\\')
# flag2=os.path.exists('D:\\picture111')
# print(flag2)
# os.remove('./2.txt')
# os.rename('./1.txt', './11111.txt')
# print(os.getcwd())
# print(os.listdir('.'))#获取当前目录下所有文件

#获取目录下包含子目录中所有文件
for root, dirs, files in os.walk('../'):
    # print(root)
    # print('---------------------------------------1')
    # print(dirs)
    # print('---------------------------------------2')
    print(files)
    # print('---------------------------------------3')
